FileDir = File.expand_path(File.dirname(__FILE__))
load "#{FileDir}/word.rb"
load "#{FileDir}/excel.rb"

word = Word.new
word.show
word.display_alerts = false
doc = word.init_document
text = doc.add_text

# 测试文本
text.section("Cover 1") do 
	"数据通信网络高级巡检报告\n巡检时间：2017-04-12"
end

# 测试表格
text.style("正文")
text.add_table(2,2) do |tbl|
	tbl.merge_row
	tbl << ["1", "2", "3"]
end
text.entry

# 测试图片
text.add_head_image(File.join(FileDir, "..", "picture.png"))
text.page_break
path = File.join(FileDir, "..", "line.png")

text.add_image(path)

# 测试图表
tbl = [
	["a", "1"],
	["b", "2"],
	["c", "3"],
	["d", "4"],
]
text.chart(tbl) do |chart|
	chart.title = "Name"
	chart.type = 5
	#chart.axes_x = "year"
	#chart.axes_y = "value"
	chart.style = 251
end

# 测试目录
doc.create_catalog

text.section("标题 1") do
	"a"
end
text.entry
text.section("标题 1") do
	"b"
end
text.entry

doc.update_catalog
